import request from '@/utils/request';
import qs from "qs";

export async function purchaseList(params) {
  const limit = params.pageSize;
  const page = params.current;
  const my_params = {
    limit: limit,
    page: page
  };
  Object.assign(params, my_params);
  delete params.current;
  delete params.pageSize;
  params.type = "1";
  return request('/supplyChain/oldSale/page', {
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}


export async function getPurchaseDetail(params) {
  return request(`/supplyChain/oldSale/details`, {
    params
  });
}
export async function getImgs(params) {
  return request(`/supplyChain/oldSale/detail`, {
    params
  });
}
export async function exportOldSaleDetails(params) {
  return request(`supplyChain/purchase/exportOldSaleDetails`, {
    method: 'GET',
    responseType: 'blob',
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}

export async function exportPrinter(params) {
  return request(`/supplyChain/oldSale/printer`, {
    method: 'GET',
    responseType: 'blob',
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}
export async function exportDriverPrinter(params) {
  return request(`/supplyChain/oldSale/driverPrinter`, {
    method: 'GET',
    responseType: 'blob',
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}
export async function changeMoney(data) {
  return request('supplyChain/driver/oldSale/changeMoney', {
    method: 'POST',
    data
  });
}

export async function getPayFiles(params) {
  return request(`/supplyChain/driver/getPayFiles`, {
    params
  });
}

export async function delPayFile(data) {
  return request(`/supplyChain/purchase/delFile`, {
    method: 'POST',
    data
  });
}
export async function revoke(data) {
  return request('supplyChain/oldSale/revoke', {
    method: 'POST',
    data
  });
}
export async function addDriverDetails(data) {
  return request('supplyChain/oldSale/addDriverDetails', {
    method: 'POST',
    data
  });
}
export async function addDriverDetailsByOrders(data) {
  return request('supplyChain/oldSale/addDriverDetailsByOrders', {
    method: 'POST',
    data
  });
}
export async function delDriver(data) {
  return request('supplyChain/oldSale/delDriver', {
    method: 'POST',
    data
  });
}
export async function confirmOrder(data) {
  return request('supplyChain/oldSale/confirmOrder', {
    method: 'POST',
    data
  });
}
export async function confirmDriver(data) {
  return request('supplyChain/oldSale/confirmDriver', {
    method: 'POST',
    data
  });
}
export async function getOrderDetailByIds(params) {
  return request(`/supplyChain/oldSale/detailsByIds`, {
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}
export async function orderConfirm(data) {
  return request('supplyChain/oldSale/orderConfirm', {
    method: 'POST',
    data
  });
}
